package com.project.Util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;

/**
 * @author lyl
 * description:转码工具类
 */
public class UtfUtil {
    public static void utfUtil(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException {
        //设置编码集，避免中文出现乱码问题
        req.setCharacterEncoding("utf-8");
        //设置相应信息的MINE类型和编码集，避免出现乱码问题（设置响应头
        resp.setContentType("text/html;charset=utf-8");
    }
}
